const { defineConfig } = require("@vue/cli-service");
const { name } = require("./package");
const path = require("path");

module.exports = defineConfig({
  transpileDependencies: true,
  devServer: {
    port: 7001,
    headers: {
      "Access-Control-Allow-Origin": "*",
    },
  },
  configureWebpack: {
    output: {
      library: `${name}-[name]`,
      libraryTarget: "umd", // 把微应用打包成 umd 库格式
      chunkLoadingGlobal: `webpackJsonp_${name}`,
    },
  },
  chainWebpack: (config) => {
    config.module
      .rule("change-prefix")
      .test(/\.js$/)
      .include.add(path.resolve(__dirname, "./node_modules/element-ui/lib"))
      .end()
      .use("change-prefix")
      .loader("change-prefix-loader")
      .options({
        prefix: "el-",
        replace: "gp-",
      })
      .end();
  },
});
